#############################################################################################
#This script gets all scripts of diversity using 8 arthropods order at multi-hierarchical levels
#We used 8 groups: Arachnda, Coleoptera, Collembola, Diptera, Hemiptera, Hymenoptera, Lepidoptera, and Myriapoda.
library(stats)
library(base)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(dplyr)
library(tidyr)
library (knitr)
library(PMCMR)
## PMCMR is superseded by PMCMRplus and will be no longer maintained. You may wish to install PMCMRplus instead.
library(vegan)
## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.5-2
library(betapart)
library(stringr)
library(permute) #Me pide que carge permute y lattice en el Rstudio que estoy usando
library(lattice)
# path to scripts Archnida and data
datafolder=setwd("~/Documents/Multihierarchical_NevadoToluca/bin/Arachnida")
#We get the diversity analysis at haplotypes, CL 3%, and CL 5% in Arachnida
source("3Com_matrixes_data_exploration_Arachnida_h_Site.R")
## Warning in Ops.factor(left, right): '>' not meaningful for factors
## `summarise()` ungrouping output (override with `.groups` argument)

## Warning in posthoc.kruskal.nemenyi.test.default(x =
## richness_Site$sample_richness_Site, : Ties are present, p-values are not
## corrected.

## Run 0 stress 0.1640223
## Run 1 stress 0.1679684
## Run 2 stress 0.1739974
## Run 3 stress 0.1683444
## Run 4 stress 0.1645922
## Run 5 stress 0.1742895
## Run 6 stress 0.1663096
## Run 7 stress 0.1691587
## Run 8 stress 0.1765081
## Run 9 stress 0.1703824
## Run 10 stress 0.1667404
## Run 11 stress 0.1766159
## Run 12 stress 0.1881831
## Run 13 stress 0.1664881
## Run 14 stress 0.1651429
## Run 15 stress 0.1778769
## Run 16 stress 0.1651427
## Run 17 stress 0.1668813
## Run 18 stress 0.1795623
## Run 19 stress 0.1701643
## Run 20 stress 0.1649558
## *** No convergence -- monoMDS stopping criteria:
## 20: stress ratio > sratmax
## species scores not available

## species scores not available

## species scores not available

## species scores not available


source("3Com_matrixes_data_exploration_Arachnida3P_Site.R")
## `summarise()` ungrouping output (override with `.groups` argument)

## Warning in posthoc.kruskal.nemenyi.test.default(x =
## richness_Site$sample_richness_Site, : Ties are present, p-values are not
## corrected.

## Run 0 stress 0.1922801
## Run 1 stress 0.1922832
## ... Procrustes: rmse 0.0005256472 max resid 0.00241487
## ... Similar to previous best
## Run 2 stress 0.1937837
## Run 3 stress 0.1937837
## Run 4 stress 0.192182
## ... New best solution
## ... Procrustes: rmse 0.01610239 max resid 0.06966978
## Run 5 stress 0.1922799
## ... Procrustes: rmse 0.0160914 max resid 0.06970306
## Run 6 stress 0.2090318
## Run 7 stress 0.1921864
## ... Procrustes: rmse 0.001686047 max resid 0.008211913
## ... Similar to previous best
## Run 8 stress 0.2144559
## Run 9 stress 0.2017443
## Run 10 stress 0.1962925
## Run 11 stress 0.204813
## Run 12 stress 0.1937838
## Run 13 stress 0.2113368
## Run 14 stress 0.2017474
## Run 15 stress 0.1937838
## Run 16 stress 0.2117359
## Run 17 stress 0.2051695
## Run 18 stress 0.1922797
## ... Procrustes: rmse 0.01610273 max resid 0.06963002
## Run 19 stress 0.196664
## Run 20 stress 0.2123748
## *** Solution reached
## species scores not available

## species scores not available

## species scores not available

## species scores not available


source("3Com_matrixes_data_exploration_Arachnida5P_Site.R")
## `summarise()` ungrouping output (override with `.groups` argument)

## Warning in posthoc.kruskal.nemenyi.test.default(x =
## richness_Site$sample_richness_Site, : Ties are present, p-values are not
## corrected.

## Run 0 stress 0.199876
## Run 1 stress 0.2203456
## Run 2 stress 0.1992482
## ... New best solution
## ... Procrustes: rmse 0.02163884 max resid 0.08464907
## Run 3 stress 0.223397
## Run 4 stress 0.1992454
## ... New best solution
## ... Procrustes: rmse 0.001427475 max resid 0.00815099
## ... Similar to previous best
## Run 5 stress 0.1992468
## ... Procrustes: rmse 0.0004223904 max resid 0.001952078
## ... Similar to previous best
## Run 6 stress 0.2106065
## Run 7 stress 0.2175375
## Run 8 stress 0.2025484
## Run 9 stress 0.2186123
## Run 10 stress 0.2024495
## Run 11 stress 0.2186139
## Run 12 stress 0.2103359
## Run 13 stress 0.2106104
## Run 14 stress 0.2087461
## Run 15 stress 0.1998754
## Run 16 stress 0.1992457
## ... Procrustes: rmse 0.0003666967 max resid 0.001487456
## ... Similar to previous best
## Run 17 stress 0.2043646
## Run 18 stress 0.2081462
## Run 19 stress 0.2121891
## Run 20 stress 0.2085521
## *** Solution reached
## species scores not available

## species scores not available

## species scores not available

## species scores not available


# path to scripts Coleoptera and data
datafolder=setwd("~/Documents/Multihierarchical_NevadoToluca/bin/Coleoptera")
source("Com_matrixes_data_exploration_Coleoptera_h_Site.R")
## Warning in Ops.factor(left, right): '>' not meaningful for factors
## `summarise()` ungrouping output (override with `.groups` argument)

## Warning in posthoc.kruskal.nemenyi.test.default(x =
## richness_Site_h$sample_richness_Site_h, : Ties are present, p-values are
## not corrected.

## Run 0 stress 9.552724e-05
## Run 1 stress 9.787677e-05
## ... Procrustes: rmse 0.0001970804 max resid 0.0006956024
## ... Similar to previous best
## Run 2 stress 9.877437e-05
## ... Procrustes: rmse 0.0001641056 max resid 0.0006501681
## ... Similar to previous best
## Run 3 stress 9.869856e-05
## ... Procrustes: rmse 0.0001318361 max resid 0.0003877093
## ... Similar to previous best
## Run 4 stress 9.304418e-05
## ... New best solution
## ... Procrustes: rmse 0.0001609752 max resid 0.0006301323
## ... Similar to previous best
## Run 5 stress 9.664324e-05
## ... Procrustes: rmse 7.73205e-05 max resid 0.0001750782
## ... Similar to previous best
## Run 6 stress 9.539234e-05
## ... Procrustes: rmse 0.0001555808 max resid 0.0005018671
## ... Similar to previous best
## Run 7 stress 9.726357e-05
## ... Procrustes: rmse 0.0001978071 max resid 0.000497889
## ... Similar to previous best
## Run 8 stress 7.737476e-05
## ... New best solution
## ... Procrustes: rmse 0.0001766167 max resid 0.0005973825
## ... Similar to previous best
## Run 9 stress 9.516042e-05
## ... Procrustes: rmse 0.0001428192 max resid 0.0004594777
## ... Similar to previous best
## Run 10 stress 9.761113e-05
## ... Procrustes: rmse 0.0001312488 max resid 0.0004007721
## ... Similar to previous best
## Run 11 stress 9.920261e-05
## ... Procrustes: rmse 0.0001340527 max resid 0.0004238194
## ... Similar to previous best
## Run 12 stress 9.560344e-05
## ... Procrustes: rmse 0.0001915908 max resid 0.0005377258
## ... Similar to previous best
## Run 13 stress 9.763345e-05
## ... Procrustes: rmse 0.0001955837 max resid 0.0005730448
## ... Similar to previous best
## Run 14 stress 9.708666e-05
## ... Procrustes: rmse 0.0001991139 max resid 0.0006428978
## ... Similar to previous best
## Run 15 stress 9.335531e-05
## ... Procrustes: rmse 0.0001663727 max resid 0.0006094566
## ... Similar to previous best
## Run 16 stress 9.487749e-05
## ... Procrustes: rmse 0.0001035847 max resid 0.00023851
## ... Similar to previous best
## Run 17 stress 9.863725e-05
## ... Procrustes: rmse 0.0001062759 max resid 0.000485651
## ... Similar to previous best
## Run 18 stress 9.133803e-05
## ... Procrustes: rmse 0.0001779409 max resid 0.00062802
## ... Similar to previous best
## Run 19 stress 9.497074e-05
## ... Procrustes: rmse 8.768534e-05 max resid 0.0002337867
## ... Similar to previous best
## Run 20 stress 9.461679e-05
## ... Procrustes: rmse 0.0001404218 max resid 0.0004913111
## ... Similar to previous best
## *** Solution reached
## Warning in metaMDS(beta.pair$beta.sim): stress is (nearly) zero: you may
## have insufficient data
## species scores not available

## Run 0 stress 0.1016899
## Run 1 stress 0.1107812
## Run 2 stress 0.1095616
## Run 3 stress 0.1098187
## Run 4 stress 0.1137073
## Run 5 stress 0.1084474
## Run 6 stress 0.1103595
## Run 7 stress 0.1100515
## Run 8 stress 0.1136891
## Run 9 stress 0.1063241
## Run 10 stress 0.1105762
## Run 11 stress 0.1030998
## Run 12 stress 0.1137284
## Run 13 stress 0.1137937
## Run 14 stress 0.1023525
## Run 15 stress 0.1123426
## Run 16 stress 0.1079861
## Run 17 stress 0.1109042
## Run 18 stress 0.1067707
## Run 19 stress 0.1095911
## Run 20 stress 0.1198716
## *** No convergence -- monoMDS stopping criteria:
## 3: no. of iterations >= maxit
## 17: stress ratio > sratmax
## species scores not available

## species scores not available

## species scores not available

## species scores not available


source("Com_matrixes_data_exploration_Coleoptera_3P_Site.R")
## `summarise()` ungrouping output (override with `.groups` argument)

## Warning in posthoc.kruskal.nemenyi.test.default(x =
## richness_Site$sample_richness_Site, : Ties are present, p-values are not
## corrected.

## Run 0 stress 0.1296922
## Run 1 stress 0.139895
## Run 2 stress 0.1300206
## ... Procrustes: rmse 0.05180756 max resid 0.2878262
## Run 3 stress 0.1314035
## Run 4 stress 0.1372969
## Run 5 stress 0.1385894
## Run 6 stress 0.1363449
## Run 7 stress 0.1269966
## ... New best solution
## ... Procrustes: rmse 0.08684451 max resid 0.2694403
## Run 8 stress 0.134147
## Run 9 stress 0.1235772
## ... New best solution
## ... Procrustes: rmse 0.04965799 max resid 0.1573321
## Run 10 stress 0.1317764
## Run 11 stress 0.1254629
## Run 12 stress 0.1344783
## Run 13 stress 0.1389731
## Run 14 stress 0.1415737
## Run 15 stress 0.1324665
## Run 16 stress 0.129953
## Run 17 stress 0.1375635
## Run 18 stress 0.1418608
## Run 19 stress 0.1413945
## Run 20 stress 0.1387772
## *** No convergence -- monoMDS stopping criteria:
## 5: no. of iterations >= maxit
## 15: stress ratio > sratmax
## species scores not available

## species scores not available

## Run 0 stress 0.1398926
## Run 1 stress 0.1384467
## ... New best solution
## ... Procrustes: rmse 0.0386572 max resid 0.1214053
## Run 2 stress 0.1330395
## ... New best solution
## ... Procrustes: rmse 0.08190981 max resid 0.2827767
## Run 3 stress 0.1409318
## Run 4 stress 0.1496547
## Run 5 stress 0.1352541
## Run 6 stress 0.1434584
## Run 7 stress 0.1420609
## Run 8 stress 0.1455931
## Run 9 stress 0.1334509
## ... Procrustes: rmse 0.05960723 max resid 0.1805138
## Run 10 stress 0.1451467
## Run 11 stress 0.1485646
## Run 12 stress 0.1412765
## Run 13 stress 0.1461685
## Run 14 stress 0.1334913
## ... Procrustes: rmse 0.02238926 max resid 0.05375086
## Run 15 stress 0.1461491
## Run 16 stress 0.1449354
## Run 17 stress 0.1352485
## Run 18 stress 0.1370881
## Run 19 stress 0.1354264
## Run 20 stress 0.1547955
## *** No convergence -- monoMDS stopping criteria:
## 20: stress ratio > sratmax
## species scores not available

## species scores not available

## species scores not available

## species scores not available


source("Com_matrixes_data_exploration_Coleoptera_5P_Site.R")
## `summarise()` ungrouping output (override with `.groups` argument)

## Warning in posthoc.kruskal.nemenyi.test.default(x =
## richness_Site0.05$sample_richness_Site0.05, : Ties are present, p-values
## are not corrected.

## Run 0 stress 0.1400952
## Run 1 stress 0.1413825
## Run 2 stress 0.1435267
## Run 3 stress 0.1436169
## Run 4 stress 0.1379026
## ... New best solution
## ... Procrustes: rmse 0.08712714 max resid 0.3348145
## Run 5 stress 0.1388775
## Run 6 stress 0.1397677
## Run 7 stress 0.1458976
## Run 8 stress 0.1408399
## Run 9 stress 0.1415957
## Run 10 stress 0.1442065
## Run 11 stress 0.1443796
## Run 12 stress 0.1409391
## Run 13 stress 0.1392186
## Run 14 stress 0.1400998
## Run 15 stress 0.1410403
## Run 16 stress 0.1461465
## Run 17 stress 0.1437058
## Run 18 stress 0.140968
## Run 19 stress 0.142444
## Run 20 stress 0.1420327
## *** No convergence -- monoMDS stopping criteria:
## 7: no. of iterations >= maxit
## 13: stress ratio > sratmax
## species scores not available

## species scores not available

## Run 0 stress 0.1639448
## Run 1 stress 0.1678622
## Run 2 stress 0.1744525
## Run 3 stress 0.1650347
## Run 4 stress 0.1730234
## Run 5 stress 0.1646985
## Run 6 stress 0.170238
## Run 7 stress 0.1739528
## Run 8 stress 0.166885
## Run 9 stress 0.1655843
## Run 10 stress 0.1637101
## ... New best solution
## ... Procrustes: rmse 0.01428983 max resid 0.05498424
## Run 11 stress 0.1722356
## Run 12 stress 0.1800045
## Run 13 stress 0.1647536
## Run 14 stress 0.1654806
## Run 15 stress 0.1672895
## Run 16 stress 0.1758105
## Run 17 stress 0.171137
## Run 18 stress 0.1835207
## Run 19 stress 0.1693005
## Run 20 stress 0.164257
## *** No convergence -- monoMDS stopping criteria:
## 20: stress ratio > sratmax
## species scores not available

## species scores not available

## species scores not available

## species scores not available


# path to scripts Coleoptera and data
datafolder=setwd("~/Documents/Multihierarchical_NevadoToluca/bin/Collembola")
source("Com_matrixes_data_exploration_Collembola_h_Site.R")
## Warning in Ops.factor(left, right): '>' not meaningful for factors
## `summarise()` ungrouping output (override with `.groups` argument)

## Warning in posthoc.kruskal.nemenyi.test.default(x =
## richness_Site_h$sample_richness_Site_h, : Ties are present, p-values are
## not corrected.

## Run 0 stress 0.1042231
## Run 1 stress 0.104223
## ... New best solution
## ... Procrustes: rmse 0.0002040128 max resid 0.001180857
## ... Similar to previous best
## Run 2 stress 0.1043388
## ... Procrustes: rmse 0.08290892 max resid 0.1998987
## Run 3 stress 0.1042235
## ... Procrustes: rmse 0.0002939513 max resid 0.001700164
## ... Similar to previous best
## Run 4 stress 0.1042229
## ... New best solution
## ... Procrustes: rmse 4.525118e-05 max resid 0.000216953
## ... Similar to previous best
## Run 5 stress 0.104338
## ... Procrustes: rmse 0.009300536 max resid 0.05088375
## Run 6 stress 0.1043394
## ... Procrustes: rmse 0.009600235 max resid 0.05267211
## Run 7 stress 0.1043085
## ... Procrustes: rmse 0.08290456 max resid 0.2000942
## Run 8 stress 0.1043086
## ... Procrustes: rmse 0.08284508 max resid 0.2001466
## Run 9 stress 0.1043388
## ... Procrustes: rmse 0.0829341 max resid 0.1999117
## Run 10 stress 0.1043362
## ... Procrustes: rmse 0.08275477 max resid 0.2000689
## Run 11 stress 0.1043131
## ... Procrustes: rmse 0.004743172 max resid 0.02269677
## Run 12 stress 0.1043103
## ... Procrustes: rmse 0.08297293 max resid 0.2000156
## Run 13 stress 0.1043091
## ... Procrustes: rmse 0.08282211 max resid 0.2001727
## Run 14 stress 0.1043085
## ... Procrustes: rmse 0.08287234 max resid 0.2001345
## Run 15 stress 0.1043087
## ... Procrustes: rmse 0.08284307 max resid 0.2001469
## Run 16 stress 0.1043085
## ... Procrustes: rmse 0.08285937 max resid 0.2001342
## Run 17 stress 0.1043087
## ... Procrustes: rmse 0.08283982 max resid 0.2001509
## Run 18 stress 0.1043084
## ... Procrustes: rmse 0.08289331 max resid 0.2001032
## Run 19 stress 0.1043087
## ... Procrustes: rmse 0.08292533 max resid 0.2000699
## Run 20 stress 0.1043389
## ... Procrustes: rmse 0.08293913 max resid 0.1999162
## *** Solution reached
## species scores not available

## species scores not available

## species scores not available

## species scores not available


source("Com_matrixes_data_exploration_Collembola_3P_Site.R")
## `summarise()` ungrouping output (override with `.groups` argument)

## Warning in posthoc.kruskal.nemenyi.test.default(x =
## richness_Site$sample_richness_Site, : Ties are present, p-values are not
## corrected.

## Run 0 stress 0.1037297
## Run 1 stress 0.1067374
## Run 2 stress 0.1074049
## Run 3 stress 0.1090234
## Run 4 stress 0.1105674
## Run 5 stress 0.1069449
## Run 6 stress 0.1100534
## Run 7 stress 0.1102973
## Run 8 stress 0.1141589
## Run 9 stress 0.1095515
## Run 10 stress 0.1081166
## Run 11 stress 0.1077708
## Run 12 stress 0.1103508
## Run 13 stress 0.1080835
## Run 14 stress 0.1105674
## Run 15 stress 0.1089478
## Run 16 stress 0.1124763
## Run 17 stress 0.1094777
## Run 18 stress 0.110222
## Run 19 stress 0.1149544
## Run 20 stress 0.1102405
## *** No convergence -- monoMDS stopping criteria:
## 20: stress ratio > sratmax
## species scores not available

## species scores not available

## species scores not available

## species scores not available


source("Com_matrixes_data_exploration_Collembola_5P_Site.R")
## `summarise()` ungrouping output (override with `.groups` argument)

## Warning in posthoc.kruskal.nemenyi.test.default(x =
## richness_Site$sample_richness_Site, : Ties are present, p-values are not
## corrected.

## Run 0 stress 0.1206288
## Run 1 stress 0.1207496
## ... Procrustes: rmse 0.06438818 max resid 0.2126625
## Run 2 stress 0.1289752
## Run 3 stress 0.1263137
## Run 4 stress 0.1262847
## Run 5 stress 0.1209384
## ... Procrustes: rmse 0.02715519 max resid 0.1660014
## Run 6 stress 0.1345762
## Run 7 stress 0.1215533
## Run 8 stress 0.1273446
## Run 9 stress 0.1213406
## Run 10 stress 0.1247885
## Run 11 stress 0.1239148
## Run 12 stress 0.1268553
## Run 13 stress 0.1217131
## Run 14 stress 0.1209385
## ... Procrustes: rmse 0.02716454 max resid 0.1659673
## Run 15 stress 0.1206288
## ... Procrustes: rmse 3.606555e-05 max resid 0.0001124391
## ... Similar to previous best
## Run 16 stress 0.122796
## Run 17 stress 0.1229115
## Run 18 stress 0.1239098
## Run 19 stress 0.1229116
## Run 20 stress 0.1207594
## ... Procrustes: rmse 0.06441344 max resid 0.212654
## *** Solution reached
## species scores not available

## species scores not available

## species scores not available

## species scores not available


####################################END######################################################################